package com.nd.android.u.ui.longClickMenu.messageList;

import android.content.Context;

import com.nd.android.u.allCommonUtils.ToastUtils;
import com.nd.android.u.controller.ChatConst.LocalMessageType;
import com.nd.android.u.controller.MessageConst.MessageState;
import com.nd.android.u.controller.innerInterface.IChatListLongClickMenu;
import com.nd.android.u.controller.innerInterface.IMessageDisplay;
import com.nd.android.u.ui.R;
import com.product.android.business.ApplicationVariable;

import ims.manager.IMSStateManager;

/**
 * [重发] 菜单项
 * @author yufeng
 * @version 创建时间：2014-7-18 上午10:40:44
 */
public class MenuItemResend implements IChatListLongClickMenu {

    private IMessageDisplay mMessage;

    @Override
    public String getLabel() {
        return ApplicationVariable.INSTANCE.applicationContext
                .getString(R.string.context_menu_item_resend);
    }

    @Override
    public void onClick(Context context) {
//        mMessage.getProccessInterface().sendMessage();
        if (IMSStateManager.getInstance()
                .isNetworkAvailable()) {
            mMessage.resend();
        } else {
            ToastUtils.display(context,
                    R.string.net_warn_no_network);
        }
    }

    @Override
    public boolean isEnable(IMessageDisplay message) {
    	mMessage=message;
        // 系统消息和应用消息没有弹出菜单, 公众号消息只有"删除"项
        if (mMessage.getMessageType() == LocalMessageType.SYSTEM || mMessage.getMessageType() == LocalMessageType.APP
                || mMessage.getMessageType() == LocalMessageType.PUBLIC_NUMBER) {
            return false;
        }

        return !(mMessage.getExtraFlag() != MessageState.SEND_FAIL
                || !mMessage.isFromSelf());
    }

}
